package com.smarttiger.zero.admin.dto;

import com.smarttiger.zero.admin.entity.DictionaryModel;
import com.smarttiger.zero.admin.entity.UsersGroupModel;
import com.smarttiger.zero.admin.entity.UsersModel;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;


public class UsersGroupDto extends BaseDto {

    private String name;
    private String note;

    private List<UsersModel> usersModelList;

    public List<UsersModel> getUsersModelList() {
        return usersModelList;
    }

    public void setUsersModelList(List<UsersModel> usersModelList) {
        this.usersModelList = usersModelList;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    static public UsersGroupDto tranlate(UsersGroupModel f){
        UsersGroupDto t = new UsersGroupDto();
        BeanUtils.copyProperties(f,t,"usersModelList");
        return t;
    }

    static public UsersGroupDto tranlateAll(UsersGroupModel f){
        UsersGroupDto t = new UsersGroupDto();
        BeanUtils.copyProperties(f,t);

        List<UsersModel> rall = new ArrayList<>();
        f.getUsersModelList().forEach(e->{
            UsersModel dto = new UsersModel();
            BeanUtils.copyProperties(e,dto);
            rall.add(dto);
        });
        t.setUsersModelList(rall);

        return t;
    }

    static public List<DictionaryDto> tranlateList(List<DictionaryModel> f){
        List<DictionaryDto> t = new ArrayList<>();
        f.forEach(e->{
            DictionaryDto dto = DictionaryDto.tranlate(e);
            t.add(dto);
        });
        return t;
    }


}
